/**
 *
 * 标签相关接口
 *
 */

 import request from '@/utils/request'
 export function getTagList(params) {
    return request({
      url: '/api/tags',
      method: 'get',
      params
    })
  }
  export function delTag(id) {
    return request({
      url: `/api/tags/${id}`,
      method: 'delete',
    })
  }
  export function getRules() {
    return request({
      url: '/api/resource-rules',
      method: 'get',
    })
  }
  export function addTag(data) {
    return request({
      url: '/api/tags',
      method:'post',
      data,
    })
  }
  export function editTag(id,data) {
    return request({
      url: `/api/tags/${id}`,
      method:'put',
      data,
    })
  }

  export function detailTag(id) {
    return request({
      url: `/api/tags/${id}`,
      method:'get',
    })
  }
  export function downloadTemplate (params,scheduleType) {
    return request({
      url:'/api/tags/export',
      method:'get',
      params,
      responseType: 'blob'
    }).then((res) => {
      // console.log( res.data)
      const link = document.createElement('a')
      let blob = new Blob([res],{type: 'application/vnd.ms-excel'});
      link.style.display = 'none'
      link.href = URL.createObjectURL(blob);
      link.setAttribute('download', '标签列表'+ '.xlsx')
      document.body.appendChild(link)
      link.click()
      document.body.removeChild(link)
  })
   }
